//
//  XQPhotoCell.swift
//  PhotoSelect
//
//  Created by 王帅强 on 2019/1/7.
//  Copyright © 2019 王帅强. All rights reserved.
//

import UIKit
import Photos

class XQPhotoCell: UICollectionViewCell {

    @IBOutlet weak var selectBtn: UIButton!
    @IBOutlet weak var imageView: UIImageView!

    override func awakeFromNib() {
        super.awakeFromNib()
    }


    func configData(photo: XQPhotoModel) {
        selectBtn.isSelected = photo.selected


        let options: PHImageRequestOptions = PHImageRequestOptions.init()
        options.resizeMode = .fast
        options.deliveryMode = .highQualityFormat
        options.isNetworkAccessAllowed = true

        PHCachingImageManager.default().requestImage(for: photo.asset, targetSize: CGSize(width: 300, height: 300), contentMode: .aspectFill, options: options) { (result, info) in
            self.imageView.image = result
        }

    }

}
